home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / bisect_pdf.pro < prev    next >
Text File  |  1997-07-08  |  1KB  |  46 lines

  1. ;$Id: bisect_pdf.pro,v 1.4 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1994-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5. ;+
  6. ; NAME:
  7. ;       BISECT_PDF
  8. ;
  9. ; PURPOSE:
  10. ;       This function computes the cutoff value x such that the probabilty
  11. ;       of an observation from the given distribution, less than x, is a(0).
  12. ;       u and l are the upper and lower limits for x, respectively.
  13. ;       a(1) and a(2) are degrees of freedom, if appropriate.
  14. ;       funct is a string specifying the probability density function.
  15. ;       BISECT_PDF is not intended to be a user-callable function.
  16. ;-
  17.  
  18. function bisect_pdf, a, funct, u, l, del
  19.   sa = size(a)
  20.   if (n_elements(del) eq 0) then del = 1.0e-6
  21.   p = a[0]
  22.   if (p lt 0 or p gt 1) then return, -1
  23.   up = u
  24.   low = l
  25.   mid = l + (u - l) * p
  26.   count = 1
  27.   while (abs(up - low) gt del*mid) and (count lt 100) do begin
  28.    if n_elements(z) ge 1 then begin 
  29.      if z gt p then  up = mid else low = mid
  30.      mid = (up + low)/2.
  31.    endif
  32.   case n_elements(a) of
  33.     1: z = call_function(funct, mid)
  34.     2: z = call_function(funct, mid, a[1])
  35.     3: z = call_function(funct, mid, a[1], a[2])
  36.     else: return, -1
  37.   endcase
  38.   count = count + 1
  39.   endwhile
  40.   return, mid
  41. end
  42.  
  43.  
  44.  
  45.   
  46.